; squeak3.8_win_chn1click.nsi
;
; This scripts will pack squeak image, source files, and virtual machine
; to one single exe file.
; The purpose of this installer is to provide a "one click" thing
; for the Newbies.

;--------------------------------

;InitPluginsDir
; The name of the installer
Name "Squeak 3.8 Chinese all in one Installer"

; The file to write
OutFile "squeak3.8chn_win_setup.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\Squeak3.8CHN"

;--------------------------------

; Pages

Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------

; Languages supported
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
LoadLanguageFile "${NSISDIR}\Contrib\Language files\SimpChinese.nlf"

; Set name using the normal interface (Name command)
LangString Name ${LANG_ENGLISH} "English"
LangString Name ${LANG_SIMPCHINESE} "Simplified Chinese"
;Name $(Name)


;--------------------------------

; The stuff to install
Section "" ;No components page, name is not important

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Copy files
  Call InstallVM
  Call InstallImage
  Call InstallChange
  Call InstallSource
  Call InstallChinese
  
  ; Create short cut
  CreateDirectory "$SMPROGRAMS\Squeak\3.8CHN\"
  CreateShortcut "$SMPROGRAMS\Squeak\3.8CHN\squeak.lnk" $INSTDIR\Squeak.exe '"$INSTDIR\SqueakPlugin-dev-zh-cn.image"'  
  CreateShortcut "$DESKTOP\squeak3.8CHN.lnk" $INSTDIR\Squeak.exe '"$INSTDIR\SqueakPlugin-dev-zh-cn.image"'  
  CreateShortcut "$SMPROGRAMS\Squeak\3.8CHN\uninstall.lnk" "$INSTDIR\uninstall.exe"  
  
  WriteUninstaller "$INSTDIR\uninstall.exe"
  
  Exec '$INSTDIR\Squeak.exe "$INSTDIR\SqueakPlugin-dev-zh-cn.image"'
  SetAutoClose true
SectionEnd ; end the section

Section "Uninstall"
  ; remove files
  Delete "$INSTDIR\*.image"
  Delete "$INSTDIR\*.changes"
  Delete "$INSTDIR\*.dll"
  Delete "$INSTDIR\*.sources"
  Delete "$INSTDIR\*.exe"
  Delete "$INSTDIR\zh-cn.translation"
  RMDir  "$INSTDIR"

  ; remove short cuts  
  Delete "$SMPROGRAMS\Squeak\3.8CHN\squeak.lnk"
  Delete "$SMPROGRAMS\Squeak\3.8CHN\uninstall.lnk"
  Delete "$DESKTOP\squeak3.8CHN.lnk"
  RMDir "$SMPROGRAMS\Squeak\3.8CHN"
  SetAutoClose true
SectionEnd 

Function InstallVM
  File Squeak.exe
  File SqueakFFIPrims.dll
FunctionEnd

Function InstallImage
  File SqueakPlugin-dev-zh-cn.image
FunctionEnd

Function InstallChange
  File SqueakPlugin-dev-zh-cn.changes
FunctionEnd

Function InstallSource
  File SqueakV3.sources
FunctionEnd

Function InstallChinese
  File zh-cn.translation
FunctionEnd

Function .onInit

    ;Language selection dialog
    Push ""
    Push ${LANG_ENGLISH}
    Push English
    Push ${LANG_SIMPCHINESE}
    Push "Simplified Chinese"
    Push A ; A means auto count languages
           ; for the auto count to work the first empty push (Push "") must remain
    LangDLL::LangDialog "Installer Language" "Please select the language of the installer"

    Pop $LANGUAGE
    StrCmp $LANGUAGE "cancel" 0 +2
        Abort
FunctionEnd
